﻿/********--------******** 产品还原解析类 ********--------********/

/*
 * PolicyNodeMeta 保险原型树的节点
 *
 */
function PolicyNodeMeta(nodeJson) {
    // 节点原始json数据
    var nodeJsonValue;
    // 字段名称
    var fieldName;
    // 显示中文名称
    var displayName;
    // 数据类型
    var eDataType;
    // 节点Json数据值
    var valueJson;
    // 提示信息
    var infoTip;
    // 路径编码
    var pathCode;
    // 比较方法（只有可以比较的节点该属性才有意义）
    var compareMethod;
    // 比较返回结果（只有可以比较的节点该属性才有意义）
    var returnResult;

    // 创建newPolicyNodeMeta方法(私有方法)
    var newPolicyNodeMeta = function (nodeJson) {
        nodeJsonValue = convertStr2Json(nodeJson);
        var jsonObj = nodeJsonValue;

        try {
            fieldName = jsonObj.fieldName;// 字段名称
            //displayName = jsonObj.displayName;// 显示中文名称
            eDataType = jsonObj.eDataType; // 数据类型
            valueJson = jsonObj.valueJsonStr;// 原始Json数据
            infoTip = jsonObj.infoTip;// 提示信息
            pathCode = jsonObj.pathCode;// 路径编码
            compareMethod = jsonObj.compareMethod;// 比较方法（只有可以比较的节点该属性才有意义）
            returnResult = jsonObj.returnResult;// 比较返回结果（只有可以比较的节点该属性才有意义）
        } catch (e) {
            writeLog(e, "元树节点的Json数据格式不正确");
        }
    }
    //构造方法（解析Json字符串）
    newPolicyNodeMeta(nodeJson);

    // 实现fromJson方法
    this.fromJson = function (nodeJson) {
        newPolicyNodeMeta(nodeJson);
    }
    // 实现toJson方法
    this.toJson = function () {
        return convertJson2Str(nodeJsonValue);
    }

    // get方法
    this.getFieldName = function () {
        return conver2StrIfNull(fieldName);
    }
    //this.getDisplayName = function () {
    //    return conver2StrIfNull(displayName);
    //}
    this.getValueJson = function () {
        return conver2StrIfNull(valueJson);
    }
    this.getEDataType = function () {
        return conver2StrIfNull(eDataType);
    }
    this.getInfoTip = function () {
        return conver2StrIfNull(infoTip);
    }
    this.getPathCode = function () {
        return conver2StrIfNull(pathCode);
    }
    this.getCompareMethod = function () {
        return conver2StrIfNull(compareMethod);
    }
    this.getReturnResult = function () {
        return conver2StrIfNull(returnResult);
    }
    // 获取易保通类型的数据
    this.getEBTValue = function () {
        try {
            var valJson = convertStr2Json(conver2StrIfNull(valueJson));
            var ebtType = valJson.eDataType;
            var value = valJson.value;
            if (ebtType.toLowerCase() == "eareabenefit") {
                return new EAreaBenefit(value);
            } else if (ebtType.toLowerCase() == "eumbrellabenefit") {
                return new EUmbrellaBenefit(value);
            }
            else if (ebtType.toLowerCase().indexOf("controller") >= 0) {
                return new EController(value);
            }
            else if (ebtType.toLowerCase().indexOf("ebenefittablecol") >= 0) {
                return new BenefitTableColumn(value);
            } else {
                return value;
            }
        } catch (e) {
            writeLog(e, "Node节点的valueJsonStr的数据结构错误" + valueJson);
        }
    }
    // 设置普通节点的值
    this.setNodeValue = function (value) {
        var valJson = convertStr2Json(conver2StrIfNull(valueJson));
        valJson.value = value;
        valueJson = valJson;
    }

    // 控件类型的节点可以设置前台选中的值
    this.setSelectedIndex = function (selIndex) {
        if (this.getEDataType().toLowerCase().indexOf("controller") >= 0) {
            var tempValue = convertStr2Json(valueJson);
            tempValue.value.selectedIndex = selIndex;
            valueJson = tempValue;
        }
    }
    // 控件类型的节点可以设置前台选中的值
    this.setSelectedValue = function (selValue) {
        if (this.getEDataType().toLowerCase().indexOf("controller") >= 0) {
            var tempValue = convertStr2Json(valueJson);
            var itemArray = eval(tempValue.value.items);
            var selIndex = $.inArray(selValue - 0, itemArray);
            if (selIndex >= 0) {
                tempValue.value.selectedIndex = selIndex;
                valueJson = tempValue;
            }
        }
    }
}

/*
 * EController 数据类型 控件类型
 *
 */
function EController(dataJson) {
    // 类型原始Json数据
    var originalJsonValue;
    // 元素
    var items = new Array();
    // 控件元素的显示名称数组
    var itemsNameArray = new Array();
    // 控件的显示名称
    var itemDisplayNames = new Array();
    var displayName = "";
    // 元素的活性状态数组
    var itemsEnableArray = new Array();

    // 默认选中索引
    var defaultIndex;
    // 自动选择规则
    var autoSelLogic;
    // 前台选中的索引
    var selectedIndex;
    // 前台选中的值
    var selectedValue;
    // 控件显示顺序
    var sortNo;

    var newEController = function (dataJson) {
        // 保存原始Json数据
        originalJsonValue = convertStr2Json(dataJson);
        try {
            var jsonObj = originalJsonValue;
            var itemIds = convertStr2Json(jsonObj.items);
            for (var item in itemIds) {
                items.push(itemIds[item]);
            }
            // 获取显示名称
            var itemNames = convertStr2Json(jsonObj.itemDisPlay);
            for (var name in itemNames) {
                itemDisplayNames.push(itemNames[name]);
            }
            displayName = jsonObj.displayName;
            defaultIndex = jsonObj.defaultIndex;
            autoSelLogic = jsonObj.autoSelLogic;
            selectedIndex = jsonObj.selectedIndex;
            sortNo = jsonObj.displayWeight;
            selectedValue = items[selectedIndex];
        } catch (e) {
            writeLog(e, "不是合法的Controller类型Json数据");
        }
    }
    // 构造方法，数据解析
    newEController(dataJson);

    // 实现fromJson方法
    this.fromJson = function (dataJson) {
        newEController(dataJson);
    }
    // 实现toJson方法
    this.toJson = function () {
        return convertJson2Str(originalJsonValue);
    }

    // get方法
    this.getItems = function () {
        return conver2StrIfNull(items);
    }
    this.getItemsName = function () {
        return conver2StrIfNull(itemsNameArray);
    }
    this.getItemsEnableArray = function () {
        return conver2StrIfNull(itemsEnableArray);
    }
    this.setItemEnableArray = function (enableArr) {
        itemsEnableArray = null;
        itemsEnableArray = enableArr;
    }
    // get方法
    this.getItemDisplayNames = function () {
        return conver2StrIfNull(itemDisplayNames);
    }

    this.getDisplayName = function () {
        return conver2StrIfNull(displayName);
    }

    this.getDefaultIndex = function () {
        return conver2StrIfNull(defaultIndex);
    }
    this.getAutoSelLogic = function () {
        return conver2StrIfNull(autoSelLogic);
    }
    this.getSelectedIndex = function () {
        return conver2StrIfNull(selectedIndex);
    }
    this.getSelectedValue = function () {
        if (null == selectedValue || selectedValue == "undefined") {
            return items[selectedIndex];
        } else {
            return selectedValue;
        }
    }
    this.getSelectedName = function () {
        return itemDisplayNames[selectedIndex];
    }
    this.getSortNo = function () {
        if (sortNo == null || sortNo == "undefined") {
            return 0;
        } else {
            return sortNo;
        }

    }

    // set方法
    this.setSelectedIndex = function (selIndex) {
        if (!isNaN(selIndex) && (selIndex >= 0 || selIndex < items.length)) {
            selectedIndex = selIndex;
            selectedValue = items[selectedIndex];
        }
    }
    // set方法
    this.setSelectedValue = function (selValue) {
        var index = $.inArray(selValue - 0, items);
        if (index >= 0) {
            selectedIndex = index;
            selectedValue = selValue;
        }
    }
}
/*
 * EAreaBenefit 数据类型 面积利益图
 *
 */
function EAreaBenefit(dataJson) {
    // 类型原始Json数据
    var originalJsonValue;
    // 最长终期年龄
    var maxInsuredAge;
    // 利益项目名称
    var name;
    // 排列顺序（左侧导航栏排序使用）
    var sortNo;
    // 条款原文
    var termText;
    // 利益锚点位置
    var benefitAnchor;
    // 图形透明度
    var transparency;
    // 图形显示上层加权
    var imgLevelWeight;
    // 利益表达式
    var expression;
    // 口述内容
    var dictation;
    // 利益语音包
    var voicePackage = new Array();
    // 图形颜色
    var color;
    // 图形样式 柱状图 线状图
    var imgStyle;

    var newEAreaBenefit = function (dataJson) {
        originalJsonValue = convertStr2Json(dataJson);
        try {
            maxInsuredAge = originalJsonValue.maxInsuredAge;
            name = originalJsonValue.name;
            sortNo = originalJsonValue.sortNo;
            imgLevelWeight = originalJsonValue.imgLevelWeight
            termText = originalJsonValue.termText;
            benefitAnchor = originalJsonValue.benefitAnchor;
            transparency = originalJsonValue.transparency;
            imgLevelWeight = originalJsonValue.imgLevelWeight;
            expression = originalJsonValue.expression;
            dictation = originalJsonValue.dictation;
            //voicePackage = originalJsonValue.voicePackage;

            var voices = convertStr2Json(originalJsonValue.voicePackage);
            for (var item in voices) {
                voicePackage.push(voices[item]);
            }

            color = originalJsonValue.color;
            imgStyle = originalJsonValue.imgStyle;
        } catch (e) {
            writeLog(e, "不是合法的EAreaBenefit类型Json数据");
        }
    }
    // 构造方法
    newEAreaBenefit(dataJson);

    // 实现fromJson方法
    this.fromJson = function (dataJson) {
        newEAreaBenefit(dataJson);
    }
    // 实现toJson方法
    this.toJson = function () {
        convertJson2Str(originalJsonValue);
    }
    // 实现get方法
    this.getName = function () {
        return conver2StrIfNull(name);
    }
    // 获取最长终期年龄
    this.getMaxInsuredAge = function () {
        return Number(conver2StrIfNull(maxInsuredAge));
    }
    this.getSortNo = function () {
        return conver2StrIfNull(sortNo);
    }
    this.getImgLevelWeight = function () {
        if (isEmpty(imgLevelWeight)) {
            return 0;
        } else {
            return imgLevelWeight;
        }
    }
    this.getTermText = function () {
        return conver2StrIfNull(termText);
    }
    this.getBenefitAnchor = function () {
        return conver2StrIfNull(benefitAnchor);
    }
    this.getTransparency = function () {
        return conver2StrIfNull(transparency);
    }
    this.getExpression = function () {
        return conver2StrIfNull(expression);
    }
    this.getDictation = function () {
        return conver2StrIfNull(dictation);
    }
    this.getVoicePackage = function () {
        return conver2StrIfNull(voicePackage);
    }
    this.getColor = function () {
        return conver2StrIfNull(color);
    }
    this.getImgStyle = function () {
        return conver2StrIfNull(imgStyle);
    }
}
/*
 * EUmbrellaBenefit 数据类型 面积利益图
 *
 */
function EUmbrellaBenefit(dataJson) {
    // 类型原始Json数据
    var originalJsonValue;
    // 利益项目名称
    var name;
    // 排列顺序（左侧导航栏排序使用）
    var sortNo;
    // 条款原文
    var termText;
    // 利益表达式
    var expression;
    // 口述内容
    var dictation;
    // 利益语音包
    var voicePackage = new Array();
    // 图像类型 伞状图
    var imgStyle;

    var newEUmbrellaBenefit = function (dataJson) {
        // 保存原始Json数据
        originalJsonValue = convertStr2Json(dataJson);
        try {
            name = originalJsonValue.name;
            sortNo = originalJsonValue.sortNo;
            termText = originalJsonValue.termText;
            expression = originalJsonValue.expression;
            dictation = originalJsonValue.dictation;
            //voicePackage = originalJsonValue.voicePackage;

            var voices = convertStr2Json(originalJsonValue.voicePackage);
            for (var item in voices) {
                voicePackage.push(voices[item]);
            }

            imgStyle = originalJsonValue.imgStyle;
        } catch (e) {
            writeLog(e, "不是合法的EUmbrellaBenefit类型Json数据");
        }
    }
    // 构造方法
    newEUmbrellaBenefit(dataJson);

    // 实现fromJson方法
    this.fromJson = function (dataJson) {
        newEAreaBenefit(dataJson);
    }
    // 实现toJson方法
    this.toJson = function () {
        convertJson2Str(originalJsonValue);
    }
    // 实现get方法
    this.getName = function () {
        return conver2StrIfNull(name);
    }
    this.getSortNo = function () {
        return conver2StrIfNull(sortNo);
    }
    this.getTermText = function () {
        return conver2StrIfNull(termText);
    }
    this.getExpression = function () {
        return conver2StrIfNull(expression);
    }
    this.getVoicePackage = function () {
        return conver2StrIfNull(voicePackage);
    }
    this.getImgStyle = function () {
        return conver2StrIfNull(imgStyle);
    }
    this.getDictation = function () {
        return conver2StrIfNull(dictation);
    }
}


/*
 * BenefitTableColumn 利益表列
 *
 */
function BenefitTableColumn(colJson) {
    // 利益列原始Json
    var bftColJson;
    // 附件表名
    var bftTblName;
    // 映射DB列
    var bftRefColIndex;
    // 查表方法
    var searchMethod;
    // 排序权重
    var sequenceWeight;

    newBenefitTableColumn = function (colJson) {
        bftColJson = colJson;
        bftTblName = colJson.dbFieldCode;
        bftRefColIndex = colJson.mapping;
        searchMethod = colJson.queryFunction;
        //sequenceWeight = "";//colJson.sequenceWeight;
    }
    newBenefitTableColumn(colJson);
    this.fromJson = function (colJson) {
        newBenefitTableColumn(colJson);
    }
    this.getBftTblName = function () {
        return bftTblName;
    }
    this.getRefColIndex = function () {
        return bftRefColIndex;
    }
    this.getSearchMethod = function () {
        return searchMethod;
    }
    this.getSequenceWeight = function () {
        return sequenceWeight;
    }

}
/*
 * PolicyPrototype 保险原型
 *
 */
function PolicyPrototype(treeJson) {
    // 原始Json数据
    var originalJsonValue;
    // 原型节点列表
    var pnmList = new Array();

    var newPolicyPrototype = function (treeJson) {
        originalJsonValue = convertStr2Json(treeJson);
        try {
            var productObj = originalJsonValue.productObj;
            for (var node in productObj) {
                var pnmNode = new PolicyNodeMeta(productObj[node]);
                pnmList.push(pnmNode);
            }
        } catch (e) {
            writeLog(e, "不是合法的保险原型类型Json数据");
        }
    }
    newPolicyPrototype(treeJson);

    // get方法
    this.getPNMList = function () {
        return pnmList;
    }
    // 根据字段ID获取节点
    this.getNodeByFieldName = function (fieldName) {
        try {
            for (var i = 0; i < pnmList.length; i++) {
                var node = pnmList[i];
                var nodeFieldName = node.getFieldName();
                if (nodeFieldName.toLowerCase() == fieldName.toLowerCase()) {
                    return node;
                }
            }
        } catch (e) {
            writeLog(e, "不存在fieldName:" + fieldName);
            return null;
        }
    }
    // 根据节点类型获取节点
    this.getNodesByEDataType = function (ebtType) {
        var nodeList = new Array();
        for (var i = 0; i < pnmList.length; i++) {
            var node = pnmList[i];
            var nodeType = node.getEDataType();
            if (nodeType.toLowerCase() == ebtType.toLowerCase()) {
                nodeList.push(node);
            }
        }
        return nodeList;
    }
}


/*
 * InsuranceObj 被保人
 *
 */
function InsuredPerson(strName, iSex, iAge, strBirthday, iProfession) {
    var id;
    var name;
    var sex;
    var age;
    var birthday;
    var profession;
    var relation;

    var newInsuredPersion = function (iId, strName, iSex, iAge, strBirthday, iProfession, strRelation) {
        id = iId;
        name = strName;
        if (iSex == 0 || iSex == 1) {
            sex = iSex;
        } else {
            writeLog(e, "性别类型不正确（0：女 1：男）");
        }
        if (!isNaN(iAge) && iAge >= 0) {
            age = iAge;
        } else {
            writeLog(e, "年龄类型不正确");
        }
        if (strBirthday != null && typeof (strBirthday) != typeof (undefined)) {
            birthday = strBirthday.substr(0, 10);
        }
        if (!isNaN(iProfession) && iProfession >= 1 && iProfession <= 6) {
            profession = iProfession;
        } else {
            writeLog(e, "职业类型不正确,必须为1-6之间的数字");
        }
        relation = strRelation;
    }
    if (arguments.length == 7) {
        newInsuredPersion(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
    } else if (arguments.length != 0) {
        writeLog(null, "不是合法的被保人信息");
    }

    // get方法
    this.getID = function () {
        return conver2StrIfNull(id);
    }
    this.getName = function () {
        return conver2StrIfNull(name);
    }
    this.getSexValue = function () {
        return conver2StrIfNull(sex);
    }
    this.getSexName = function () {
        if (sex == 0) {
            return "女";
        } else {
            return "男";
        }
    }
    this.getAge = function () {
        return Number(conver2StrIfNull(age));
    }
    this.getBirthday = function () {
        return conver2StrIfNull(birthday);
    }
    this.getProfession = function () {
        return conver2StrIfNull(profession);
    }
    this.getProfessionName = function () {

        var result = null;
        switch (profession-0) {
            case 1:
                result = "一类";
                break;
            case 2:
                result = "二类";
                break;
            case 3:
                result = "三类";
                break;
            case 4:
                result = "四类";
                break;
            case 5:
                result = "五类";
                break;
            case 6:
                result = "六类";
                break;
        }
        return result;
    }
    this.getRelation = function () {
        return conver2StrIfNull(relation);
    }

    // set方法
    this.setName = function (strName) {
        name = strNamel
    }
    this.setSex = function (iSex) {
        if (iSex == 0 || iSex == 1) {
            sex = iSex;
        } else {
            writeLog(e, "性别类型不正确（0：女 1：男）");
        }
    }
    this.setAge = function (iAge) {
        if (!isNaN(iAge) && iAge >= 0) {
            age = iAge;
        } else {
            writeLog(e, "年龄类型不正确");
        }
    }
    this.setBirthday = function (strBirthday) {
        birthday = strBirthday;
    }
    this.setProfession = function (iProfession) {
        if (!isNaN(iProfession) && iProfession >= 1 && iProfession <= 6) {
            profession = iProfession;
        } else {
            writeLog(e, "职业类型不正确,必须为1-6之间的数字");
        }
    }
}

/*
 * InsuranceObj 保险产品
 *
 */
function InsuranceObj(productId, insrdPerson, rateTableId, searchJson) {

    // 方案使用产品主键
    var proposalProductKey;
    this.setProposalProductKey = function (ppKey) {
        proposalProductKey = ppKey;
    }
    this.getProposalProductKey = function () {
        return proposalProductKey;
    }
    //方案的Viewer使用的特征值
    var productFeature;
    this.setProductFeature = function (pFeature) {
        productFeature = pFeature;
    }
    this.getProductFeature = function () {
        return productFeature;
    }

    // 独立费率表控件的ID
    var rateTableId = rateTableId;
    // product 表中的检索层属性
    var searchProperty = eval(searchJson);
    // 被保人
    var insuredPerson;
    var PIAge;
    this.getPIAge = function () {
        return PIAge;
    }
    var PISex;
    this.getPISex = function () {
        return PISex;
    }
    var PIOccupationCategory;
    this.getPIOccupationCategory = function () {
        return PIOccupationCategory;
    }
    // 产品原型
    var product;
    // 保险条款地址（HTML）
    var policyTermURL;
    // 条款列表地址（xml）
    var chapterURL;
    // 投保规则地址
    var purchaseRuleURL;
    // 产品彩页地址
    var catloguePictureURL = new Array();
    // 面积利益图
    var areaBenefitList;
    // 利益公式中使用的变量定义字符串
    var expVariable;
    // 利益公式中使用的变量
    var ExpVariables;
    // 伞状利益图
    var umbrellaBenefitList;
    // 前台控件类型节点
    var controllers;
    // 保额
    var coverage = 0;
    // 保费
    var premium = 0;
    // 费率辅助对象
    var RaterHelper;
    // 是否是特殊类型产品（基础列+比例列）
    var IsSpecialProduct;


    // 获取产品对应的Json数据块
    var findProductJson = function (productId) {
        var productJson = convertStr2Json($("#" + productId).val());
        //$("#" + productId).remove();
        return productJson;
    }
    var newInsuranceObj = function (productId, insrdPerson) {
        // 保存被保人信息
        insuredPerson = insrdPerson;
        // 获取产品的Json数据块
        var productJson = findProductJson(productId);
        product = new PolicyPrototype(productJson);

        PIAge = product.getNodeByFieldName("PIAge").getEBTValue();
        PISex = product.getNodeByFieldName("PISex").getEBTValue();
        PIOccupationCategory = product.getNodeByFieldName("PIOccupationCategory").getEBTValue();

        product.getNodeByFieldName("PIAge").setNodeValue(insuredPerson.getAge());
        product.getNodeByFieldName("PISex").setNodeValue(insuredPerson.getSexValue());
        product.getNodeByFieldName("PIOccupationCategory").setNodeValue(insuredPerson.getProfession());

        var maxInsAgeObj = product.getNodeByFieldName("IMaxInsureAge");
        if (maxInsAgeObj != null) {
            var maxAge = maxInsAgeObj.getEBTValue();
            if (maxAge < insrdPerson.getAge()) {
                insrdPerson.setAge(maxAge);
            }
        }

    }
    // 构造方法
    newInsuranceObj(productId, insrdPerson);

    // 获取被保人
    this.getInsuredPerson = function () {
        return insuredPerson;
    }
    this.setInsuredPerson = function (insPerson) {
        insuredPerson = insPerson;
    }

    // 获取保险条款
    this.getPolicyTermURL = function () {
        if (isEmpty(policyTermURL)) {
            var tempNode = product.getNodeByFieldName("policyTermURL");
            policyTermURL = tempNode.getEBTValue();
        }
        return policyTermURL;
    }
    // 获取条款列表地址
    this.getChapterURL = function () {
        if (isEmpty(chapterURL)) {
            var tempNode = product.getNodeByFieldName("chapterURL");
            chapterURL = tempNode.getEBTValue();
        }
        return chapterURL;
    }
    // 获取产品的投保规则文件的地址
    this.getPurchaseRuleURL = function () {
        if (isEmpty(purchaseRuleURL)) {
            var tempNode = product.getNodeByFieldName("purchaseRuleURL");
            purchaseRuleURL = tempNode.getEBTValue();
        }
        return purchaseRuleURL;
    }
    // 获取保险的产品彩页地址
    this.getCatloguePictureURL = function () {
        if (isEmpty(catloguePictureURL)) {
            var tempNode = product.getNodeByFieldName("catloguePictureURL");
            var urls = tempNode.getEBTValue();
            for (var picUrl in urls) {
                catloguePictureURL.push(urls[picUrl]);
            }
        }
        return catloguePictureURL;
    }
    // 获取保险面积利益列表
    this.getAreaBenefitList = function () {
        if (isEmpty(areaBenefitList)) {
            areaBenefitList = product.getNodesByEDataType("EAreaBenefit");
            areaBenefitList.sort(function (bnftA, bnftB) {
                if (bnftA.getEBTValue().getSortNo() < bnftB.getEBTValue().getSortNo()) {
                    return 1;
                } else {
                    return 0;
                }
            });
        }
        return areaBenefitList;
    }
    // 获取利益全表列信息的列表
    this.getBftColInfoList = function () {
        var colList = product.getNodesByEDataType("EBftTblCol");
        colList.sort(function (colA, colB) {
            if (colA.getEBTValue().getSequenceWeight() < colB.getEBTValue().getSequenceWeight()) {
                return 1;
            } else {
                return 0;
            }
        });
        return colList;
    }
    // 获取保险伞状利益列表
    this.getUmbrellaBenefitList = function () {
        if (isEmpty(umbrellaBenefitList)) {
            umbrellaBenefitList = product.getNodesByEDataType("EUmbrellaBenefit");
            umbrellaBenefitList.sort(function (bnftA, bnftB) {
                if (bnftA.getEBTValue().getSortNo() > bnftB.getEBTValue().getSortNo()) {
                    return 1;
                } else {
                    return 0;
                }
            });
        }
        return umbrellaBenefitList;
    }
    // 获取控件类型的节点
    this.getControllerNodes = function () {
        if (isEmpty(controllers)) {
            controllers = product.getNodesByEDataType("EIntArrayController");
            var dcontrollers = product.getNodesByEDataType("EDoubletArrayController");
            for (var i = 0; i < dcontrollers.length; i++) {
                controllers.push(dcontrollers[i]);
            }
            controllers.sort(function (contA, contB) {
                if (contA.getEBTValue().getSortNo() > contB.getEBTValue().getSortNo()) {
                    return 1;
                } else {
                    return 0;
                }
            });
        }
        return controllers;
    }
    // 获取保额
    this.getCoverage = function () {
        return getBenefitParamValue("Coverage");
    }
    // 获取保额
    this.getCoverageName = function () {
        return getBenefitParamValue("Coverage");
    }
    this.getSearchProperty = function () {
        return searchProperty;
    }
    this.getCoverageName = function () {
        var anotherField = "";
        try {
            var paramNode = product.getNodeByFieldName("CoverageUseAnotherFieldName");
            anotherField = paramNode.getEBTValue();
        } catch (e) { }
        if (anotherField == "") {
            var coverageNode = product.getNodeByFieldName("Coverage");
            return coverageNode.getEBTValue();
        } else {
            var coverageNode = product.getNodeByFieldName(anotherField);
            return coverageNode.getEBTValue().getSelectedName();
        }
    }
    // 获取保费
    this.getPremium = function () {

        premium = product.getNodeByFieldName("Premium").getEBTValue();
        return premium;
    }
    // 获取是否是特殊产品
    this.getIsSpecialProduct = function () {
        if (IsSpecialProduct == null) {
            // 判断是否是特殊类型的产品
            var rtbc = 0;
            try {
                rtbc = product.getNodeByFieldName("RateTableBaseCoverage").getEBTValue();
            } catch (e) {
                rtbc = 0;
            }
            if (rtbc == 0) {
                IsSpecialProduct = false;
            } else {
                IsSpecialProduct = true;
            }
        }
        return IsSpecialProduct;
    }
    // 获取是否是特殊产品（内部使用）
    isThisSpecialProduct = function () {
        if (IsSpecialProduct == null) {
            // 判断是否是特殊类型的产品
            var rtbc = 0;
            try {
                rtbc = product.getNodeByFieldName("RateTableBaseCoverage").getEBTValue();
            } catch (e) {
                rtbc = 0;
            }
            if (rtbc == 0) {
                IsSpecialProduct = false;
            } else {
                IsSpecialProduct = true;
            }
        }
        return IsSpecialProduct;
    }
    // 根据节点名称获取节点
    this.getNodeByFieldName = function (strFieldName) {
        var node = product.getNodeByFieldName($.trim(strFieldName));
        return node;
    }
    // 根据节点名称获取节点
    this.getNodeByModelName = function (strFieldName) {
        var nodeName = this.getNodeNameByModelName(strFieldName);
        // Model指向Node
        if (nodeName.toLowerCase().indexOf("n_") == 0) {
            if (nodeName.indexOf("(") > 0) {
                nodeName = nodeName.substring(2, nodeName.indexOf("("));
            } else {
                nodeName = nodeName.substring(2);
            }
            var node = product.getNodeByFieldName(nodeName);
            return node;
        } else if (nodeName.toLowerCase().indexOf("v_") == 0) {
            // Model 指向固定值
            return nodeName.substring(2);
        } else if (nodeName.toLowerCase().indexOf("q_") == 0) {
            // Model 指向查询层字段
            nodeName = nodeName.substring(2);
            return eval("this.getSearchProperty()." + nodeName);
        }
        return null;
    }
    // 获取利益的最大保障年龄
    this.getMaxBenefitAge = function () {
        var coverped = this.getNodeByFieldName("CoveragePeriod").getEBTValue().getSelectedValue();
        if (coverped < 0) {
            return 0 - coverped;
        }
        if (coverped > 0) {
            return insuredPerson.getAge() + Number(coverped);
        }
        if (coverped == 0 && areaBenefitList.length > 0) {
            return areaBenefitList[0].getEBTValue().getMaxInsuredAge();
        } else {
            return 105;
        }
    }
    this.getExpVariable = function () {
        if (expVariable == null) {
            expVariable = new Map();
            var tempvarNode = product.getNodeByFieldName("TempVar");
            if (null != tempvarNode) {
                var tempVar = String(tempvarNode.getEBTValue());
                if (tempVar.substring(tempVar.length - 1, tempVar.length) == ";") {
                    tempVar = tempVar.substring(0, tempVar.length - 1);
                }
                var itemArr = tempVar.split(";");
                for (var i = 0; i < itemArr.length; i++) {
                    var item = String(itemArr[i]);
                    var keyvalues = item.split("=");
                    expVariable.put(keyvalues[0], keyvalues[1]);
                }
            }
        }

        return expVariable;
    }
    // 获取指定利益的数据
    this.getBenefitDataByFieldName = function (strFieldName) {
        var benefitNode = this.getNodeByFieldName(strFieldName);
        var befexpression = benefitNode.getEBTValue().getExpression();
        return this.analyzeCountExp(befexpression);
    }
    // 获取利益公式中使用的变量值
    this.getExpVariableMap = function () {
        if (ExpVariables == null) {
            this.setExpVariableMap();
        }
        return ExpVariables;
    }
    // 根据参数名获取参数对应的值
    var getBenefitParamValue = function (paramName) {
        switch (String(paramName).toLowerCase()) {
            case "rate":
                var rater = new Rater();
                return rater.getRate();
                break;
            case "coverage":
                var anotherField = "";
                try {
                    var paramNode = product.getNodeByFieldName("CoverageUseAnotherFieldName");
                    anotherField = paramNode.getEBTValue();
                } catch (e) { }
                if (anotherField == "") {
                    var coverageNode = product.getNodeByFieldName("Coverage");
                    return coverageNode.getEBTValue();
                } else {
                    var coverageNode = product.getNodeByFieldName(anotherField);
                    return coverageNode.getEBTValue().getSelectedValue();
                }
            default:
                if (IsNumber(paramName)) {
                    return paramName;
                }
                var paramNode = product.getNodeByFieldName(paramName);
                if (paramNode == null || paramNode.length == 0) {
                    return "";
                }
                var result = 0;
                try {
                    result = paramNode.getEBTValue().getSelectedValue();
                } catch (e) {
                    result = paramNode.getEBTValue();
                }
                // 缴费期间(交多少年)
                if (paramName == "PaymentPeriod") {
                    if (result == 0) {
                        return 1;
                    } else if (result < 0) {
                        return 0 - result - insrdPerson.getAge();
                    } else {
                        return Number(result);
                    }
                }
                // 保障期间(保障多少年)
                if (paramName == "CoveragePeriod") {
                    if (result == 0) {
                        // 终身保障时：最长终期年龄-投保年龄
                        return areaBenefitList[0].getEBTValue().getMaxInsuredAge() - insrdPerson.getAge();
                    } else if (result < 0) {
                        // 至多少岁时：至年龄-投保年龄
                        return 0 - result - insrdPerson.getAge();
                    } else {
                        return Number(result);
                    }
                }
                // 绝对值字段
                if (String(paramName).toLowerCase().indexOf("abs_") >= 0) {
                    if (result == 0) {
                        // 终身保障时：最长终期年龄-投保年龄
                        return areaBenefitList[0].getEBTValue().getMaxInsuredAge() - insrdPerson.getAge();
                    } else if (result < 0) {
                        // 至多少岁时：至年龄-投保年龄
                        var iTempValue = result + insrdPerson.getAge();
                        if (iTempValue > 0) {
                            return iTempValue;
                        } else {
                            return 0 - iTempValue;
                        }
                    } else {
                        return Number(result);
                    }
                }
                return result;
        }
    }
    // 设置控件类型的节点前台选中值
    this.setControllerSelectedIndexByFieldName = function (strFieldName, selIndex) {
        if (isEmpty(controllers)) {
            controllers = product.getNodesByEDataType("EIntArrayController");
            var dcontrollers = product.getNodesByEDataType("EDoubletArrayController");
            for (var i = 0; i < dcontrollers.length; i++) {
                controllers.push(dcontrollers[i]);
            }
            controllers.sort(function (contA, contB) {
                if (contA.getEBTValue().getSortNo() < contA.getEBTValue().getSortNo()) {
                    return 1;
                } else {
                    return 0;
                }
            });
        }

        for (var i = 0; i < controllers.length; i++) {
            var tempController = controllers[i];
            var conFieldName = tempController.getFieldName();
            if (conFieldName == strFieldName) {
                tempController.setSelectedIndex(selIndex);
            }
        }
    }
    // 设置控件类型的节点前台选中值
    this.setControllerSelectedValueByFieldName = function (strFieldName, selValue) {
        if (isEmpty(controllers)) {
            controllers = product.getNodesByEDataType("EIntArrayController");
            var dcontrollers = product.getNodesByEDataType("EDoubletArrayController");
            for (var i = 0; i < dcontrollers.length; i++) {
                controllers.push(dcontrollers[i]);
            }
            controllers.sort(function (contA, contB) {
                if (contA.getEBTValue().getSortNo() < contA.getEBTValue().getSortNo()) {
                    return 1;
                } else {
                    return 0;
                }
            });
        }

        for (var i = 0; i < controllers.length; i++) {
            var tempController = controllers[i];
            var conFieldName = tempController.getFieldName();
            if (conFieldName == strFieldName) {
                tempController.setSelectedValue(selValue);
            }
        }
    }
    // 判断产品是否存在
    this.judgeModelExist = function (modelName) {
        if (this.getSearchProperty().ModelMap == null || this.getSearchProperty().ModelMap.length == 0) {
            return false;
        }
        var modelIndex = $.inArray(modelName, convertStr2Json(this.getSearchProperty().ModelMap).key);
        return modelIndex >= 0;
    }
    // 
    this.getNodeNameByModelName = function (modelName) {
        if (this.getSearchProperty().ModelMap == null || this.getSearchProperty().ModelMap.key.length == 0) {
            return "";
        }
        var modelMap = convertStr2Json(this.getSearchProperty().ModelMap);
        var modelIndex = $.inArray(modelName, modelMap.key);
        if (modelIndex < 0) {
            return "";
        }
        return modelMap.value[modelIndex];
    }

    // 设置保额
    this.setCoverage = function (dblCoverage) {
        product.getNodeByFieldName("Coverage").setNodeValue(dblCoverage);
        //coverage = dblCoverage;
    }
    this.getCoverageName = function () {
        var anotherField = "";
        try {
            var paramNode = product.getNodeByFieldName("CoverageUseAnotherFieldName");
            anotherField = paramNode.getEBTValue();
        } catch (e) { }
        if (anotherField == "") {
            var coverageNode = product.getNodeByFieldName("Coverage");
            return coverageNode.getEBTValue();
        } else {
            var coverageNode = product.getNodeByFieldName(anotherField);
            return coverageNode.getEBTValue().getSelectedName();
        }
    }
    // 设置保费
    this.setPremium = function (dblPremium) {
        product.getNodeByFieldName("Premium").setNodeValue(dblPremium);
        //premium = dblPremium;
    }
    // 计算设置利益公式中使用的变量值
    this.setExpVariableMap = function () {
        if (ExpVariables != null) {
            ExpVariables = null;
        }
        ExpVariables = new Map();
        // 获取利益公式中使用的变量定义字符串
        var tempExpVars = this.getExpVariable();
        for (var i = 0; i < tempExpVars.size() ; i++) {
            var tempVar = this.analyzeCountExp(tempExpVars.element(i).value);
            var tempKey = tempExpVars.element(i).key;
            ExpVariables.put(tempKey, tempVar);
        }
    }
    //// 获取Model对应的利益列的信息
    //this.getBenefitTblColByModelName = function (modelName) {
    //    var nodeName = this.getNodeNameByModelName(modelName);
    //    if (nodeName.length == 0) {
    //        return "";
    //    }
    //    var colJsonInfo = { "tblName": "", "lineIndex": "", "lineCount": "", "colIndex": "" };
    //    var colInfo = this.getNodeByFieldName(nodeName).getEBTValue();
    //    colJsonInfo.tblName = colInfo.getBftTblName();
    //    colJsonInfo.lineCount = this.getNodeByFieldName("CoveragePeriod").getEBTValue().getSelectedValue();
    //    colJsonInfo.colIndex = colInfo.getRefColIndex();
    //    var searchMethod = colInfo.getSearchMethod();
    //    // 获取易保通利益表达式中普通变量名称（即用<>括起来的变量）
    //    var params = getBenefitExpressionParam(searchMethod);
    //    // 将普通变量替换为具体的值
    //    for (var pindex = 0; pindex < params.length; pindex++) {
    //        var paramPart = "<" + params[pindex] + ">";
    //        var paramValue = Number(getBenefitParamValue(params[pindex]));
    //        searchMethod = searchMethod.replaceAll(paramPart, paramValue);
    //    }
    //    colJsonInfo.lineIndex = eval(searchMethod);
    //    return colJsonInfo;
    //}
    // 获取Model对应的利益列的信息
    this.getBenefitTblColByFieldName = function (fieldName) {
        var colJsonInfo = { "tblName": "", "colIndex": "", "query": ""};
        var colInfo = this.getNodeByFieldName(fieldName).getEBTValue();
        colJsonInfo.tblName = colInfo.getBftTblName();
        colJsonInfo.colIndex = colInfo.getRefColIndex();
        var searchMethod = colInfo.getSearchMethod();//GetBnftCol(SexSet,AgeSet,PaymentPeriod)
        searchMethod = searchMethod.replace("GetBnftCol(", "");
        searchMethod = searchMethod.replace(")", "");

        var queryArr = searchMethod.split(",");
        var queryStr = "";
        for (var i = 0; i < queryArr.length; i++) {
            var tempNode = this.getNodeByFieldName(queryArr[i]);
            if (tempNode.getEDataType().toLowerCase().indexOf("controller") < 0) {
                if (tempNode.getFieldName().toLowerCase().indexOf("sexset") >= 0) {
                    queryStr = queryStr + insuredPerson.getSexValue() + ",";
                } else if (tempNode.getFieldName().toLowerCase().indexOf("occupation") >= 0) {
                    queryStr = queryStr + insuredPerson.getProfession() + ",";
                } else if (tempNode.getFieldName().toLowerCase().indexOf("ageset") >= 0) {
                    queryStr = queryStr + insuredPerson.getAge() + ",";
                } else if (tempNode.getFieldName().toLowerCase().indexOf("piage") >= 0) {
                    queryStr = queryStr + insuredPerson.getAge() + ",";
                }
            } else {
                if (tempNode.getFieldName().toLowerCase().indexOf("sexset") >= 0) {
                    queryStr = queryStr + insuredPerson.getSexValue() + ",";
                } else if (tempNode.getFieldName().toLowerCase().indexOf("occupation") >= 0) {
                    queryStr = queryStr + insuredPerson.getProfession() + ",";
                } else if (tempNode.getFieldName().toLowerCase().indexOf("ageset") >= 0) {
                    queryStr = queryStr + insuredPerson.getAge() + ",";
                } else if (tempNode.getFieldName().toLowerCase().indexOf("piage") >= 0) {
                    queryStr = queryStr + insuredPerson.getAge() + ",";
                } else {
                    queryStr = queryStr + parseInt(tempNode.getEBTValue().getSelectedValue()) + ",";
                }
            }
        }
        colJsonInfo.query = queryStr.substr(0,queryStr.length-1);
        return colJsonInfo;
    }
    /*
     * 替换口述内容中的利益部分
     * 
     * diction：口述内容
     *
     */
    this.replaceDictionExpression = function (diction) {
        var splitIndexs = getIndexs(diction, "!");
        if (splitIndexs.length % 2) {
            writeLog(new Error("口述内容中的公式不匹配"), "!的数量不匹配");
            return diction;
        }
        var benefitNames = new Array();
        for (var i = 0; i < splitIndexs.length - 1; i = i + 2) {
            var dicExp = String(diction).substring(splitIndexs[i], splitIndexs[i + 1] + 1);
            benefitNames.push(dicExp);
        }
        for (var i = 0; i < benefitNames.length; i++) {
            diction = String(diction).replace(benefitNames[i], (this.analyzeCountExp(benefitNames[i]) - 0).toFixed(2));
        }
        return diction;
    }

    // 解析并计算利益表达式
    this.analyzeCountExp = function (engineExp) {
        // 将公式中的<x>替换为坐标轴的具体值
        var expression = engineExp;
        // 获取易保通利益表达式中普通变量名称（即用<>括起来的变量）
        var params = getBenefitExpressionParam(expression);
        // 将普通变量替换为具体的值
        for (var pindex = 0; pindex < params.length; pindex++) {
            var paramPart = "<" + params[pindex] + ">";
            var paramVlaue = getBenefitParamValue(params[pindex]);
            var paramR;
            if (paramVlaue.length > 0) {
                paramR = Number(paramVlaue);
            } else {
                paramR = paramVlaue;
            }
            expression = expression.replaceAll(paramPart, paramR);
        }
        // 获取利益表达式中的利益变量的名称（即用$$括起来的变量）
        var benefitParams = getBenefitExpressionBenefitParam(expression);
        // 将利益变量替换为具体的值
        var varsMap = this.getExpVariable();
        for (var pindex = 0; pindex < benefitParams.length; pindex++) {
            var paramPart = "$" + benefitParams[pindex] + "$";
            // 将利益变量替换为具体的值（具体值为数组）
            var paramValue = this.getExpVariableMap().get(benefitParams[pindex]);
            expression = expression.replaceAll(paramPart, paramValue);
        }
        // 计算利益公式中的引擎部分
        expression = ReplaceExpEngine(expression);
        return expression;
    }

    // 费率表数据部分
    var rateDate;
    // 费率获取方法
    var getRateMethod;
    // 费率表列因子部分
    var colFactors;
    // 列偏移量Map
    var colOffSetMap; //= {
    //偏移名称：偏移量 例如 Ofst(3)(2): 15 
    //意思为：第4（第一种是0）种因子选择第3个选项的偏移量是 15
    //}
    // 费率表行因子部分
    var rowFactors;//= { "min": 0, "max": 65 };

    // 获取费率
    var Rater = function () {
        // 获取用于查找费率表的列及行的因子
        var getRowAndColFactors = function () {
            if (isEmpty(getRateMethod)) {
                var getRateMethodNode = product.getNodeByFieldName("GetRateMethod");
                getRateMethod = getRateMethodNode.getEBTValue();
            }
            if (IsNumber(getRateMethod)) {
                return;
            }
            // 获取列因子(新逻辑)
            if (isEmpty(colFactors)) {
                colFactors = new Array();
                var startIndex = getRateMethod.indexOf(",") + 1;
                var endIndex = getRateMethod.indexOf(")");
                facNames = getRateMethod.substring(startIndex, endIndex);
                var factors = String(facNames).split(",");
                for (var i = 0; i < factors.length; i++) {
                    var tempNode = product.getNodeByFieldName(factors[i]);
                    colFactors.push(tempNode);
                }
            }
            // 获取行因子（新逻辑）
            if (isEmpty(rowFactors)) {
                rowFactors = [];
                var startIndex = getRateMethod.indexOf("(") + 1;
                var endIndex = getRateMethod.indexOf(",");
                rowFacName = getRateMethod.substring(startIndex, endIndex);

                var rowNode = product.getNodeByFieldName(rowFacName);

                var rowControl = rowNode.getEBTValue();
                rowFactors = rowControl.getItems();
            }
        }
        // 收集计算列偏移量Map的数据
        var setColOffSetMap = function () {
            if (!isEmpty(colOffSetMap)) {
                return;
            }
            // 费率为常数时，不需要设置费率列偏移量
            if (IsNumber(getRateMethod)) {
                return;
            }
            // 特殊类型产品，使用特殊列偏移量Map
            if (isThisSpecialProduct()) {
                setSpecialColOffSetMap();
                return;
            }
            colOffSetMap = {};
            // 遍历费率的全部列类型的因子
            var childItems = 0;
            for (var i = colFactors.length - 1; i >= 0; i--) {
                // 选中某种类型的因子，对该类型的因子的可选项进行拆分利用，计算偏移量
                var curitems = colFactors[i].getEBTValue().getItems();
                if (i == colFactors.length - 1) {
                    for (var k = 0; k < curitems.length; k++) {
                        colOffSetMap["Ofs(" + i + ")(" + curitems[k] + ")"] = k;
                    }
                } else {
                    for (var k = 0; k < curitems.length; k++) {
                        colOffSetMap["Ofs(" + i + ")(" + curitems[k] + ")"] = childItems * k;
                    }
                }
                if (childItems == 0) {
                    childItems = curitems.length;
                } else if (curitems.length != 1) {
                    childItems = childItems * curitems.length;
                }
            }
        }
        // 获取特殊的列偏移量Map的数据（最后为固定的两列）
        var setSpecialColOffSetMap = function () {
            if (!isEmpty(colOffSetMap)) {
                return;
            }
            // 费率为常数时，不需要设置费率列偏移量
            if (IsNumber(getRateMethod)) {
                return;
            }
            colOffSetMap = {};
            // 遍历费率的全部列类型的因子
            var childItems = 2;
            for (var i = colFactors.length - 1; i >= 0; i--) {
                // 选中某种类型的因子，对该类型的因子的可选项进行拆分利用，计算偏移量
                var curitems = colFactors[i].getEBTValue().getItems();
                for (var k = 0; k < curitems.length; k++) {
                    colOffSetMap["Ofs(" + i + ")(" + curitems[k] + ")"] = childItems * k;
                }
                if (childItems == 0) {
                    childItems = curitems.length;
                } else if (curitems.length != 1) {
                    childItems = childItems * curitems.length;
                }
            }
            colOffSetMap["Ofs(" + colFactors.length + ")(RTBC" + 0 + ")"] = 0;
            colOffSetMap["Ofs(" + colFactors.length + ")(RTBC" + 1 + ")"] = 1;
        }

        // 计算行偏移量的方法
        var getRowOffset = function (intRowFactor) {
            //var minvalue = rowFactors["min"] - 0;
            //var maxvalue = rowFactors["max"] - 0;
            //intRowFactor = intRowFactor - 0;

            //if (minvalue > intRowFactor || maxvalue < intRowFactor) {
            //    return -1;
            //} else {
            //    return intRowFactor - minvalue;
            //}
            // 新逻辑
            return $.inArray(intRowFactor, rowFactors);
        }
        // 计算列偏移量的方法
        var getColOffset = function (jsonColFac) {
            // 是特殊产品
            if (isThisSpecialProduct()) {
                return getSpecialColOffset(jsonColFac);
            }
            var colIndex = 0;
            jsonColFac = convertStr2Json(jsonColFac);
            for (var i = 0; i < jsonColFac.length; i++) {
                var key = "Ofs(" + i + ")(" + jsonColFac[i] + ")";
                colIndex = colIndex + (colOffSetMap[key] - 0);
            }
            return colIndex;
        }
        // 计算特殊列偏移量的方法
        // 返回类型[基础列索引值，比例列索引值]
        var getSpecialColOffset = function (jsonColFac) {
            var colIndex = 0;
            jsonColFac = convertStr2Json(jsonColFac);
            // 获取正常费率因子的偏移量
            for (var i = 0; i < jsonColFac.length; i++) {
                var key = "Ofs(" + i + ")(" + jsonColFac[i] + ")";
                colIndex = colIndex + (colOffSetMap[key] - 0);
            }
            return "[" + colIndex + "," + (colIndex - 0 + 1) + "]";
        }

        // 获取费率表的行值，用于查找行坐标
        var getRateTableRowValue = function () {
            var startIndex = getRateMethod.indexOf("(") + 1;
            var endIndex = getRateMethod.indexOf(",");
            rowFacName = getRateMethod.substring(startIndex, endIndex);
            var factors = String(rowFacName).split(",");

            if (factors[0].toLowerCase().indexOf("age") >= 0) {
                return insuredPerson.getAge();
            } else if (factors[0].toLowerCase().indexOf("occupationset") >= 0) {
                return insuredPerson.getProfession();
            } else if (factors[0].toLowerCase().indexOf("sex") >= 0) {
                return insuredPerson.getSexValue();
            }
        }
        // 获取费率表的列值，用于查找列坐标
        var getRateTableColValue = function () {
            // 获取费率表列索引
            var factValues = "[";
            // 获取当前费率因子的值
            for (var i = 0; i < colFactors.length; i++) {
                var tempNode = colFactors[i];
                // 不是显示控件的值时需要取被保人的信息
                if (tempNode.getEDataType().toLowerCase().indexOf("hidecontroller") >= 0) {
                    if (tempNode.getFieldName().toLowerCase().indexOf("sex") >= 0) {
                        factValues = factValues + insuredPerson.getSexValue() + ",";
                    } else if (tempNode.getFieldName().toLowerCase().indexOf("occupationset") >= 0) {
                        factValues = factValues + insuredPerson.getProfession() + ",";
                    }
                } else {
                    factValues = factValues + tempNode.getEBTValue().getSelectedValue() + ",";
                }
            }
            factValues = factValues.substr(0, factValues.length - 1) + "]";
            return factValues;
        }

        // 获取费率表数据部分
        if (isEmpty(rateDate)) {
            if (isEmpty(getRateMethod)) {
                var getRateMethodNode = product.getNodeByFieldName("GetRateMethod");
                getRateMethod = getRateMethodNode.getEBTValue();
            }
            // 费率为常数时，不需要查找费率
            if (!IsNumber(getRateMethod)) {
                var rateNode = product.getNodeByFieldName("RateTable");
                // 没有费率表节点，或者节点值为空时，获取独立费率表的值
                if (rateNode == null || rateNode.getEBTValue().length == 0) {
                    rateDate = eval($("#" + rateTableId).value());
                    $("#" + rateTableId).remove();
                } else {
                    rateDate = eval(rateNode.getEBTValue());
                }


            }
        }
        // 获取用于查找费率表的列及行的因子
        getRowAndColFactors();
        // 收集计算列偏移量Map的数据
        setColOffSetMap();
        this.getRate = function () {
            // 费率为常数时，不需要查找费率
            if (IsNumber(getRateMethod)) {
                return getRateMethod;
            }
            // 获取费率表行索引
            var rowValue = getRateTableRowValue() - 0;
            var colValue = getRateTableColValue();

            var rowOffset = getRowOffset(rowValue) - 0;
            var colOffset = getColOffset(colValue);

            try {
                // 是特殊产品
                if (isThisSpecialProduct()) {
                    var baseCol = eval(colOffset)[0] - 0;
                    var persentCol = eval(colOffset)[1] - 0;
                    return "[" + rateDate[rowOffset][baseCol] + "," + rateDate[rowOffset][persentCol] + "]";
                } else {
                    return rateDate[rowOffset][colOffset - 0];
                }
            } catch (e) {
                writeLog(new Error("费率表查找失败"));
                return 0;
            }
        }
        // 获取费率表的行
        this.getRateRow = function () {
            // 费率为常数时，不需要查找费率
            if (IsNumber(getRateMethod)) {
                return getRateMethod;
            }
            // 获取费率表行索引
            var rowValue = getRateTableRowValue() - 0;
            var rowOffset = getRowOffset(rowValue) - 0;
            try {
                return rateDate[rowOffset];
            } catch (e) {
                writeLog(new Error("费率表查找失败"));
                return 0;
            }
        }
        // 查找费率
        // rowValue:行因子的值
        // colValues：列因子的值的数组[col1Value,col2Value,col3Value...]
        this.findRate = function (rowValue, colValues) {
            var rowOffset = getRowOffset(rowValue) - 0;
            var colOffset = getColOffset(colValues) - 0;
            try {
                return rateDate[rowOffset][colOffset];
            } catch (e) {
                writeLog(new Error("费率表查找失败"));
                return 0;
            }
        }
    }

    this.getRate = function () {
        if (RaterHelper == null || isEmpty(RaterHelper)) {
            RaterHelper = new Rater();
        }
        return RaterHelper.getRate();
    }

    //this.showRate = function () {
    //    return this.getRate();
    //}
    // 获取列偏移量的Map对象
    this.getColOffsetMap = function () {
        if (RaterHelper == null || isEmpty(RaterHelper)) {
            RaterHelper = new Rater();
        }
        return colOffSetMap;
    }

    // 查找费率
    // rowValue:行因子的值
    // colValues：列因子的值的数组[col1Value,col2Value,col3Value...]
    this.findRate = function (rowVal, colVals) {
        if (RaterHelper == null || isEmpty(RaterHelper)) {
            RaterHelper = new Rater();
        }
        return RaterHelper.findRate(rowVal, colVals);
    }
    // 获取费率表的行
    this.getRateTblRow = function () {
        if (RaterHelper == null || isEmpty(RaterHelper)) {
            RaterHelper = new Rater();
        }
        return RaterHelper.getRateRow();
    }
}